<?php

class UserModel extends Model{

	public $table = 'user';

	public function addUser(){
		// $_POST['password'] = md5($_POST['password']);
		//$pwd = Q('password');//Q 可以取 get post 里面的值
			//取那个字段  默认值 回调函数
		$_POST['password'] = Q('password',0,'md5');
		if($this->add()){
			return true;
		}else{
			return false;
		}
	}

	public function login(){
		$username = Q('username');
		$password = Q('password',0,'md5');
		$re = $this->where(array('username'=>$username,'password'=>$password))->find();
		unset($re['password']);
		if($re){
			return $re;
		}else{
			return false;
		}
	}
}

?>